package com.example.baselibrary.Utils;

import android.os.CountDownTimer;

public class TimeCountDownUtil {

    private static TimeOver timeOver;
    private static CountDownTimer timer;

    public static void CountDownTime(int tiem1) {
        timer = new CountDownTimer(tiem1*1000, 1000) {
            @Override
            public void onTick(long millisUntilFinished) {
                LogUtil.d(millisUntilFinished / 1000 + "");
                timeOver.timeShow(millisUntilFinished / 1000 + "");
            }

            @Override
            public void onFinish() {
                timeOver.timeOverNow();

            }
        };
        timer.start();
    }

    public static void closeCountTime(){
        if (timer != null) {
            timer.cancel();
        }

    }

    public interface TimeOver {
        void timeOverNow();

        void timeShow(String timeShow);
    }



    public static void setTimeOverListener(TimeOver time) {
        timeOver = time;
    }
}
